package cn.study.daemonthreadTest;

import java.util.concurrent.ExecutionException;
/**
 * @Author     ：跟大佳一起学架构(Java)
 * @Description：守护线程的使用
 */
public class DaemonThread {
	private static class UseThread extends Thread{
		@Override
		public void run() {
			try {
				while (true) {
					System.out.println(Thread.currentThread().getName()  + " I am extends Thread.");
				}
			} finally {
				//守护线程中finally不一定起作用
				System.out.println(" .............finally");
			}
		}
	}

	public static void main(String[] args)
			throws InterruptedException, ExecutionException {
		UseThread useThread = new UseThread();
		useThread.setDaemon(true);
		useThread.start();
		Thread.sleep(1000);
		System.out.println("main end");
	}
}
